<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, 
initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>Document</title>
</head>
<body>
	<script src="./node_modules/redux/dist/redux.js"></script>
	<script>
		// console.log( Redux );

		// 创建 reducer
		let reducer = (state,action)=>{
				// console.log( state.now )
			// if( action.type === "ADD" ){
			// 	return Object.assign( {},state,{ now: state.now+1 } );
			// }else if( action.type === "MINUS" ){
			// 	return Object.assign( {},state,{ now: state.now-1 } );
			// }else{
			// 	return state;
			// }
			switch (action.type) {
				case "ADD":
					return Object.assign( {},state,{ now: state.now+1 } );
					break;
				case "MINUS":
					return Object.assign( {},state,{ now: state.now-1 } );
					break;
				default:
					return state
					break;
			}
		};

		// 创建 store
		let store = Redux.createStore( reducer,{now:0} );
		
		store.dispatch({
			type: "ADD"
		});
		store.dispatch({
			type: "ADD"
		});
		store.dispatch({
			type: "MINUS"
		});

		console.log( store.getState() );

	</script>
</body>
</html>